package com.icewld.alarmofremindingme;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    Intent intent;
    SoundMaker sm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        intent = new Intent(getBaseContext(), TimetriggerService.class);
        sm = new SoundMaker(getApplicationContext());

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void StartService(View v){
        startService(intent);
        Toast.makeText(getApplicationContext(), "服务开启成功", Toast.LENGTH_SHORT).show();
    }

    public void StopService (View v){
        stopService(intent);
        Toast.makeText(getApplicationContext(), "服务停止成功", Toast.LENGTH_SHORT).show();
    }

    public void TextPlay1(View v){
        try {
            sm.MakeSound("learn");
        }
        catch (Exception e){
            Toast.makeText(getApplicationContext(), "播放失败", Toast.LENGTH_SHORT);
        }
    }

    public void TextPlay2(View v){
        try {
            sm.MakeSound("enjoy");
        }
        catch (Exception e){
            Toast.makeText(getApplicationContext(), "播放失败", Toast.LENGTH_SHORT);
        }
    }
    public void TextPlay3(View v){
        try {
            sm.MakeSound("getup");
        }
        catch (Exception e){
            Toast.makeText(getApplicationContext(), "播放失败", Toast.LENGTH_SHORT);
        }
    }
}
